package com.xc.content.utils;

import com.xc.content.exception.BusinessException;
import com.xc.content.exception.DatabaseException;
import com.xc.content.exception.SystemException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: hyacinth
 * @CreateTime: 2025-01-03
 * @Version: 1.0
 */
@Slf4j
@Component
public class ExceptionUtil {

    public DatabaseException handleDatabaseException(String message, int errorCode, Exception e) {
        log.error(message + ": {}", e.getMessage(), e);
        return new DatabaseException(errorCode, message, e);
    }


    public SystemException handleSystemException(String message, int errorCode, Exception e) {
        log.error(message + ": {}", e.getMessage(), e);
        return new SystemException(errorCode, message, e);
    }

    public BusinessException handleBusinessException(String message, int errorCode, Exception e){
        log.error(message + ": {}", e.getMessage(), e);
        return new BusinessException(errorCode, message, e);
    }
}
